package com.platform.api;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.platform.annotation.IgnoreAuth;
import com.platform.entity.AdEntity;
import com.platform.service.AdService;
import com.platform.util.ApiBaseAction;
import com.platform.utils.R;

import io.swagger.annotations.Api;

@Api(tags = "API首页广告接口")
@RestController
@RequestMapping("/api/ad")
public class ApiAdController extends ApiBaseAction {

    @Autowired
    private AdService adService;

    /**
     * 查看列表
     */
    @IgnoreAuth
    @RequestMapping("/list/{positionId}")
    public R list(@PathVariable("positionId") Integer positionId) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("adPositionId", positionId);
        params.put("enabled", 1);
        List<AdEntity> banners = adService.queryList(params);
        return R.ok().put("banners", banners);
    }
    
    
}
